#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int res=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){res=(res<<1)+(res<<3)+(c^48);c=getchar();}
	return res*f;
}
void write(int x)
{
	if(x<0)x=-x,putchar('-');
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
int n,r;
int p[114514],sum[114514];
int cnt;
int main()
{
	freopen("permutation.in","r",stdin);
	freopen("permutation.out","w",stdout);
	n=read(),r=read();
	if(r<=2)
	{
		if(n==1) write(1);
		else if(n==2) puts("1 2");
		else if(n==3)
		{
			if(r==1) puts("3 1 2");
			else puts("3 2 1");
		}
		else
		{
			cout<<"3 1 2 ";
			for(int i=4;i<=n-2;i++) write(i),putchar(' ');
			if(r==1) write(n-1),putchar(' '),write(n);
			else write(n),putchar(' '),write(n-1);
		}
		return 0;
	}
	for(int i=1;i<=n;i++) p[i]=i;
	do
	{
		for(int i=1;i<=n;i++) sum[i]=sum[i-1]+p[i];
		int flag=1;
		for(int i=1;i<n;i++) if(sum[i]<=p[i+1]) flag=0;
		if(flag) 
		{
			++cnt;
			if(cnt==r)
			{
				for(int i=1;i<=n;i++) write(p[i]),putchar(' ');
				break;
			}
		} 
	}while(next_permutation(p+1,p+n+1));
	return 0;
}

